// app.js
App({
globalData:{
    avatarUrl:"../../images/mine/defaultimage.png",
    nickName:"点击获取个人信息",
    isActive:true,
    oppenid:"",
    address:""
},
//在下想要一进入小程序就得到oppenid
onLaunch(){
var that=this;
    wx.login({
      success:function(res){
        console.log(res.code)
         if (res.code) {
             wx.request({
               url: 'https://www.linjianyi.link/WxOpenData',
               data: {
                 //用户的个人code
                 js_code: res.code
               },
               method: 'GET',
               //请求头
               header: { 'content-type': 'application/json'},
               //获取成功,得到不同用户对不同小程序的oppenid
               success: function(openIdRes){
               that.globalData.oppenid= openIdRes.data.openid;
               console.log( openIdRes.data.openid)
             
               },
               fail: function(error) {
                   console.info("获取用户openId失败");
       
               }
            })
          }
          
      }
    })
}

})
